StrictlyPositiveInt

@Serializable(with = StrictlyPositiveIntSerializer::class)
@Since(version = KotoolsTypesVersion.V1_1_0)
value class StrictlyPositiveInt : NonZeroInt, PositiveInt

Represents an integer number of type Int that is greater than zero.

You can use the toStrictlyPositiveInt function for creating an instance of this type.


Serialization and deserialization

The serialization and deserialization processes of this type behave like for the Int type.

Here's an example of Kotlin code that encodes and decodes this type using the JavaScript Object Notation (JSON) format from kotlinx.serialization:

val number: StrictlyPositiveInt = 123.toStrictlyPositiveInt()
.getOrThrow()
val encoded: String = Json.encodeToString(number)
println(encoded) // 123
val decoded: StrictlyPositiveInt = Json.decodeFromString(encoded)
println(decoded == number) // true

Types

Link copied to clipboard
object Companion

Contains declarations for holding or building a StrictlyPositiveInt.

Functions

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
open infix operator override fun compareTo(other: AnyInt): Int

Compares this integer with the other one for order. Returns zero if this integer equals the other one, a negative number if it's less than the other one, or a positive number if it's greater than the other one.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun AnyInt.div(other: NonZeroInt): Int
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun PositiveInt.div(other: StrictlyNegativeInt): NegativeInt
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun PositiveInt.div(other: StrictlyPositiveInt): PositiveInt

Divides this integer by the other one, truncating the result to an integer that is closer to zero.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun AnyInt.minus(other: Int): Int
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun AnyInt.minus(other: AnyInt): Int

Subtracts the other integer from this one.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun AnyInt.plus(other: Int): Int
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun AnyInt.plus(other: AnyInt): Int

Adds the other integer to this one.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun AnyInt.rem(other: NonZeroInt): Int
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun PositiveInt.rem(other: NonZeroInt): PositiveInt

Calculates the remainder of truncating division of this integer by the other one.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun AnyInt.times(other: Int): Int
@Since(version = KotoolsTypesVersion.V4_1_0)
operator fun AnyInt.times(other: AnyInt): Int

Multiplies this integer by the other one.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_0_0)
open override fun toInt(): Int

Returns this integer as an Int.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_0_0)
open override fun toString(): String

Returns the string representation of this integer.

Link copied to clipboard
@ExperimentalSince(version = KotoolsTypesVersion.V4_4_0)
operator fun AnyInt.unaryMinus(): AnyInt
@ExperimentalSince(version = KotoolsTypesVersion.V4_4_0)
operator fun NonZeroInt.unaryMinus(): NonZeroInt
@ExperimentalSince(version = KotoolsTypesVersion.V4_4_0)
operator fun PositiveInt.unaryMinus(): NegativeInt
@ExperimentalSince(version = KotoolsTypesVersion.V4_4_0)
operator fun StrictlyPositiveInt.unaryMinus(): StrictlyNegativeInt

Returns the negative of this integer number.